<template>
  <a-spin :spinning="uploading" tip="上传中...">
    <div class="uplaodBox">
      <a-row class="head">
        <div style="cursor: pointer;" @click="goback">
          <a-icon type="left" />
          <div class="left2">返回</div>
        </div>
        <a-col class="title">
          <strong>导入定薪</strong>
        </a-col>
      </a-row>
      <div class="ant-upload-select-text-box" style="padding-top: 24px">
        <a-upload style="cursor: pointer" ref="upload" :file-list="fileList" :remove="handleRemove" :before-upload="beforeUpload">
          <img :src="uploadImg" style="width: 139px;height: 106px" />
          <div class="ant-modal-body">
            <div style="font-size: 12px;color: #666;">
              点击添加文件或将文件拖拽到此处
            </div>
            <div style="font-size: 12px;color: #999">
              (文件大小不超过5M)
            </div>
          </div>
        </a-upload>
      </div>
      <div class="tipBox">
        <a-row style="color: #252525;font-size: 16px;font-weight: 500;padding-bottom: 10px;">
          温馨提示
        </a-row>
        <a-row>
          <a-col :span="12">
            <div>
              1、建议通过标准模板进行导入,点击
              <span @click="download" class="primary_color" style="font-size: 12px;cursor:pointer">
                下载标准模板
              </span>
            </div>
            <div>2、不支持复合表头</div>
            <div>3、只能导入系统中已有的员工工资数据</div>
            <div>4、工资项目需与员工的薪酬结构保持一致</div>
            <div>5、重名员工通过手机号识别</div>
          </a-col>
        </a-row>
      </div>
      <a-modal v-model="dialogFailVisible" title="未成功名单" width="800px" @ok="handleFailClose">
        <a-table :row-key="d => d.id" :columns="columns" :data-source="Faildata" :pagination="false" />
      </a-modal>
    </div>
  </a-spin>
</template>
<script>
import UploadMixin from "xqjr-plugin-common/UploadOrExport/uploadMixin";
const mixin = new UploadMixin();
import { getToken } from "xqjr-module-auth";
import axios from "axios";
import qs from "qs";
const columns = [
  {
    title: "行号",
    dataIndex: "id",
    key: "id"
  },
  {
    title: "姓名",
    dataIndex: "name",
    key: "name"
  },
  {
    title: "原因",
    dataIndex: "reason",
    key: "reason"
  }
];

export default {
  mixins: [mixin],
  data() {
    return {
      columns,
      uploadImg: require("@/assets/img/uploadImg.png"),
      params: {
        templateName: "allEmployeeSalary.xlsx"
      },
      url: `/salary/api/v1/excel/template/download`,
      excelName: "定薪导入模板.xlsx"
    };
  },

  created() {
    const companyId = this.$store.state.hr.companyId;
    this.action = `/salary/api/v1/empFixedSalaries/import?companyId=${companyId}&force=false`;
  },
  methods: {
    handleUploadError() {
      this.$message.warning("没有文件");
    }
  }
};
</script>
<style lang="scss" scoped>
.uplaodBox {
  padding-bottom: 24px;
  .head {
    .anticon-left {
      z-index: 3;
      left: 24px;
      position: absolute;
      color: #595959;
      font-size: 20px;
      margin-top: 21px;
      color: #c0c0c0;
    }
    .left2 {
      z-index: 3;
      left: 45px;
      position: absolute;
      font-size: 14px;
      cursor: pointer;
      color: #c0c0c0;
    }
    font-size: 16px;
    color: #000;
    font-weight: 500;
    text-align: center;
    line-height: 60px;
    height: 60px;
    border-bottom: 1px solid #e8e8e8;
  }
  .exportTitle {
    text-align: center;
    font-size: 16px;
    font-weight: 500;
    color: #252525;
  }
  .left2 {
    z-index: 3;
    left: 50px;
    position: absolute;
    color: #595959;
    font-size: 14px;
  }
  .anticon-left {
    z-index: 3;
    left: 24px;
    position: absolute;
    color: #d8d8d8;
    font-size: 26px;
    margin-top: 17px;
  }
  .tipBox {
    line-height: 18px;
    background: #faf9f9;
    border-radius: 4px;
    font-size: 12px;
    color: #595959;
    margin: 0 24px;
    padding: 12px;
    height: 150px;
  }
  .ant-upload-select-text-box {
    border: 1px dashed #b8b8b8;
    background: #fff;
    margin: 24px;
    text-align: center;
    border-radius: 4px;
    padding: 12px;
    cursor: default;
  }
  .ant-upload-select-text-box ::v-deep .ant-upload-list {
    display: none;
  }
  .ant-upload-list-item-name {
    text-align-last: left;
  }

  .anticon-upload {
    font-size: 40px;
  }

  .ant-modal-body {
    line-height: 24px;

    em {
      color: var(--primary);
      font-style: normal;
    }
  }
}
</style>
